package cn.hl.sfzy.controller;

import cn.hl.sfzy.entity.ConsultSpecialty;
import cn.hl.sfzy.service.impl.ConsultSpecialtyServiceImpl;
import cn.hl.sfzy.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Date 2024年10月23日
 */
//取消所有黄色警告
//@SuppressWarnings("all")
@RestController
@RequestMapping("/consultspecialty")
public class ConsultSpecialtyController {
    @Autowired
    private ConsultSpecialtyServiceImpl consultSpecialtyService;

    /**
     * id查询
     */
    @GetMapping("/findById/{id}")
    public Result findById(@PathVariable("id") Long id) {
        ConsultSpecialty consultSpecialty = new ConsultSpecialty();
        consultSpecialty.setId(id);
        List<ConsultSpecialty> list = consultSpecialtyService.find(consultSpecialty);
        return Result.success(list);
    }

    /**
     * 查询所有
     */
    @GetMapping("/findAll")
    public Result findAll() {
        List<ConsultSpecialty> list = consultSpecialtyService.find(null);
        return Result.success(list);
    }

    /**
     * 查询
     */
    @GetMapping("/find")
    public Result find(@RequestParam(defaultValue = "1") Integer pageNum,
                       @RequestParam(defaultValue = "10") Integer pageSize,
                       ConsultSpecialty consultSpecialty) {
        PageInfo<ConsultSpecialty> data = findByPage(pageNum, pageSize, consultSpecialty);
        return Result.success(data);
    }


    /**
     * 分页查询
     */
    @GetMapping("/findByPage")
    public PageInfo<ConsultSpecialty> findByPage(int pageNum, int pageSize, ConsultSpecialty consultSpecialty) {
        return consultSpecialtyService.findByPage(pageNum, pageSize, consultSpecialty);
    }


}
